In Ruby why won't `foo = true unless defined?(foo)` make the assignment?
Posted
by LeftHem
on Stack Overflow
See other posts from Stack Overflow
or by LeftHem
Published on 2010-02-18T19:39:57Z
Indexed on
2010/05/27
13:41 UTC
Read the original article
Hit count: 132
ruby
What's going on here? What is the subtle difference between the two forms of "unless"?
> irb(main):001:0> foo = true unless defined?(foo)
=> nil
irb(main):002:0> unless defined?(fooo) ; fooo = false ; end
=> false
thx
© Stack Overflow or respective owner